package com.codes;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @Description:
 * @Author: ld
 * @CreateDate: 2020/5/16
 * @UpdateUser: ld
 * @UpdateDate:
 * @Version: 1.0
 */
@Configuration
@EnableSwagger2WebMvc
//@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfiguration {
    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        System.out.println("==========================================");
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .groupName("2.X版本")
                .select()
                //这里指定Controller扫描包路径
//                .apis(RequestHandlerSelectors.basePackage("com.tim.mall.tiger"))
                 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))  //只显示加了注解的api
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("aa")
                .description("tigerNodes")
                .termsOfServiceUrl("http://localhost:8080/doc.html")
                .contact("developer@mail.com")
                .version("1.0")
                .build();
    }



}